package differenceOfSum;

public class Solution {
    public int differenceOfSum(int[] nums) {
        int sum = 0;
        int sum1 = 0;
        for (int i = 0; i < nums.length; i++) {
            sum+=nums[i];
            sum1+=f(nums[i]);
        }
        return Math.abs(sum1-sum);
    }
    private int f(int n) {
        int ans = 0;
        while (n>0) {
            ans+=n%10;
            n/=10;
        }
        return ans;
    }
}
